package com.zygh.lz.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zygh.lz.constant.SystemCon;
import com.zygh.lz.dao.GisLocationMapper;
import com.zygh.lz.dao.SectionMapper;
import com.zygh.lz.entity.Gislocation;
import com.zygh.lz.entity.Section;
import com.zygh.lz.service.GisLocationService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.vo.ResultBean;
import com.zygh.lz.vo.ResultBeans;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GisLocationServiceImpl extends ServiceImpl<GisLocationMapper, Gislocation> implements GisLocationService {

    @Resource
    private GisLocationMapper gisLocationMapper;
    @Resource
    private SectionMapper sectionMapper;


    @Override
    public ResultBean selectGisLocation(Integer id) {
        List<Gislocation> gisLocationList = gisLocationMapper.selectGisLocation(id);
        if (gisLocationList.size() > 0) {
            return ResultUtil.setOK("success", gisLocationList);
        }
        return ResultUtil.setError(SystemCon.RERROR1, "error", null);

    }

    @Override
    public ResultBeans findAreaBySectionId(Integer id) {

        Section sectionByid = sectionMapper.selectById(id);

//        Gislocation gislocation = gisLocationMapper.selectOne(Wrappers.<Gislocation>lambdaQuery()
//                .eq(Gislocation::getSysSectio nId, sectionByid.getSectionPid()));
        String gislocation = gisLocationMapper.selectBoundary(sectionByid.getSectionPid());
        if (gislocation != null) {
            return ResultUtil.resultBeansSuccess(gislocation);

        } else {
            return ResultUtil.resultBeansSuccess(null);

        }
    }


}
